home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / human interface toolbox / live scroll / initialize.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-23  |  2.8 KB  |  151 lines

  1. /*
  2.     File:        Initialize.c
  3.  
  4.     Contains:    Initialization code for this application
  5.  
  6.     Written by: Chris White    
  7.  
  8.     Copyright:    Copyright © 1996-1999 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.                 8/6/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  20.                 
  21.  
  22. */
  23.  
  24.  
  25. #pragma segment Initialize
  26.  
  27.  
  28.  
  29. // System includes
  30.  
  31. #ifndef __QUICKDRAW__
  32.     #include <Quickdraw.h>
  33. #endif
  34.  
  35. #ifndef __FONTS__
  36.     #include <Fonts.h>
  37. #endif
  38.  
  39. #ifndef __TEXTEDIT__
  40.     #include <TextEdit.h>
  41. #endif
  42.  
  43. #ifndef __DIALOGS__
  44.     #include <Dialogs.h>
  45. #endif
  46.  
  47. #ifndef __GESTALT__
  48.     #include <Gestalt.h>
  49. #endif
  50.  
  51. #ifndef __SEGLOAD__
  52.     #include <SegLoad.h>
  53. #endif
  54.  
  55.  
  56.  
  57.  
  58. // Application includes
  59.  
  60. #ifndef __BAREBONES__
  61.     #include "BareBones.h"
  62. #endif
  63.  
  64. #ifndef __PROTOTYPES__
  65.     #include "Prototypes.h"
  66. #endif
  67.  
  68.  
  69.  
  70. // static prototypes
  71. static SInt16 CheckConfiguration ( void );
  72.  
  73.  
  74.  
  75.  
  76. void InitToolbox ( void )
  77. {    
  78.     
  79.     InitGraf ( &qd.thePort );
  80.     InitFonts ( );
  81.     InitWindows ( );
  82.     InitMenus ( );
  83.     TEInit ( );
  84.     InitDialogs ( nil );
  85.     InitCursor ( );
  86.     
  87.     FlushEvents ( everyEvent, 0 );
  88.     
  89.     return;
  90. }
  91.  
  92.  
  93.  
  94. void InitApplication ( void )
  95. {
  96.     SInt16    messageCode;
  97.     
  98.     
  99.     SetMenuBar ( GetNewMBar ( kMenuBarID ) );
  100.     AppendResMenu ( GetMenuHandle ( kAppleMenu ), 'DRVR' );
  101.     DrawMenuBar ( );
  102.     
  103.     messageCode = CheckConfiguration ( );
  104.     if ( messageCode )
  105.     {
  106.         AlertUser ( messageCode, 0, nil );
  107.         ExitToShell ( );
  108.     }
  109.     
  110.     gQuit = false;                          // Initialize flag that controls main event loop
  111.     gInBackground = false;                
  112.     gSleepTime = kSleepTime;
  113.     
  114.     InstallAppleEventHandlers ( );
  115.     CreateWindow ( );
  116.     
  117.     // Create any other RoutineDescriptors we may need
  118.     gScrollControlActionUPP = NewControlActionProc ( ScrollControlActionProc );
  119.     gScrollThumbActionUPP = NewIndicatorActionProc ( ScrollThumbActionProc );
  120.     
  121.     return;
  122. }
  123.  
  124.  
  125.  
  126. static SInt16 CheckConfiguration ( void )
  127. {
  128.     SInt16        messageCode = 0;
  129.     SInt32        theResult;
  130.     OSErr        theErr;
  131.     
  132.     
  133.     // Verify that we can run on the current configuration
  134.     
  135.     // We require AppleEvent Manager and color Quickdraw
  136.     theErr = Gestalt ( gestaltAppleEventsAttr, &theResult );
  137.     if ( !(theErr == noErr && (theResult & (1L << gestaltAppleEventsPresent)) ))
  138.         messageCode = kNeedSystem7;
  139.     
  140.     theErr = Gestalt ( gestaltQuickdrawFeatures, &theResult );
  141.     if ( !(theErr == noErr && (theResult & (1L << gestaltHasColor)) ))
  142.         messageCode = kNeedColorQuickdraw;
  143.     
  144.     
  145.     return messageCode;
  146. }
  147.  
  148.  
  149.  
  150.  
  151.